﻿using System;
public delegate void ElapsedEvent();
class ExecuteTimer : IDisposable
{
    TimerConfig config;
    System.Timers.Timer timer;
    public event ElapsedEvent elapsed_event;

    public ExecuteTimer(TimerConfig config){
        this.config = config;
        timer = new System.Timers.Timer(config.Timer_interval);
    }
    public void Execute(){
        timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
        timer.Start();
        System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
    }
    void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e){
        elapsed_event();
    }

    #region IDisposable 멤버

    public void Dispose()
    {
        timer.Stop();
        timer.Close();
    }

    #endregion
}